<template>
	<view>
		<view style="color: #fff;padding: 30rpx;font-size: 50rpx;font-weight: bold;letter-spacing: 20rpx;">意见反馈</view>
		<view class="mode">
			<u-form :model="form" ref="uForm">
				<u-form-item label="意见反馈" prop="remark" label-position="top">
					<u-input v-model="form.remark" placeholder="请输入意见反馈" />
				</u-form-item>
				
			</u-form>
			
			<u-form-item :border-bottom="false" label="图片" label-width="200" label-position="top">
				<upload ref="image" type="image" @uploaded="uploaded" :afterLoadUrl="form.image_url"
					background="#FFE3DC" borderRadius="20" iconColor="#FF5D39" width="160" height="160"
					defaultLength="3"></upload>
			</u-form-item>
			
		
			
			<view style="position: absolute;bottom: 20rpx;width: 80%;left:10% ;">
				<u-button @click="submit" :custom-style="{background:'#4066F4',color:'#fff'}" shape="circle">提交</u-button>
			</view>
		</view>
		
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import upload from "@/components/upload_img.vue";
	export default {
		components: {
			upload
		},
		data() {
			return {
				form: {
				
					remark: '',
					
				},
				rules: {
				
					remark: [{
						min: 5,
						required: true,
						message: '申请说明不能少于5个字',
						trigger: 'change'
					}],
					
					
				}
			};
		},
		methods: {
			submit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						if (!this.$refs.image.afterUploadImgList.length) {
							uni.$u.toast("请上传户型图")
							return
						}
						
						this.$u.post('/user/feedback', {
							content:this.form.remark,
							image:this.$refs.image.afterUploadImgList.join(","),
						}).then(res => {
							
							this.$refs.uToast.show({
								title: '提交成功',
								type: 'success',
								back:true
							})
						}).catch(err => {})
					} else {
						
					}
				});
			}
		},
		// 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		}
	};
</script>


<style>
	page{
		background: #4066F4;
		height: 100vh;
	}
	.mode{
		height: 80vh;
		margin-top: 20rpx;
		position: relative;
	}
</style>
